#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <unordered_map>
#include <algorithm>

using namespace std;

bool containsNearbyDuplicate(vector<int>& nums, int k) {
    unordered_map<int, int> hash;
    for (int i = 0; i < nums.size(); ++i)
    {
        if (hash.count(nums[i]))
        {
            int j = hash[nums[i]];
            if (abs(i - j) <= k)
                return true;
        }
        hash[nums[i]] = i;
    }


    return false;
}

int main()
{

	return 0;
}